package net.martinimix.service.payment;

import net.martinimix.domain.order.OrderHeader;
import net.martinimix.domain.payment.Account;
import net.martinimix.domain.payment.Payment;
import net.martinimix.domain.payment.PaymentMethod;

/**
 * Provides an abstract account payment service.
 * 
 * @author Scott Rossillo
 *
 */
public abstract class AbstractAccountPaymentService implements PaymentService {

	/**
	 * Creates a new abstract account payment service.
	 */
	protected AbstractAccountPaymentService() { }
	
	/**
	 * Creates a new account payment.
	 * 
	 * @see net.martinimix.service.payment.PaymentService#createPayment(net.martinimix.domain.payment.PaymentMethod, net.martinimix.domain.order.OrderHeader)
	 */
	public Payment createPayment(PaymentMethod paymentMethod, OrderHeader orderHeader) {
		
		final Payment payment = new Payment();
		final Account account = (Account) paymentMethod;
		
		payment.setPaymentTypeId(account.getId());
		payment.setOrderHeaderId(orderHeader.getId());
		payment.setPaymentType(Payment.TYPE_ACCOUNT);
		payment.setStatusCode(Payment.STATUS_PENDING_AUTHORIZATION);
		
		return payment;
	}

}
